/**
 * @file   1088.cpp
 * @author Shuang Hu <hsmath@ubuntu>
 * @date   Sat Apr 17 22:49:19 2021
 * 
 * @brief  PAT problem 1088:operators on rational numbers
 * 
 * @time 30 minutes
 */
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
class RationalNum{
private:
    long int fenzi;
    long int fenmu;
public:
    RationalNum(long int a,long int b){
	fenzi=a;
	fenmu=b;
    }
    void yuefen(){
	if(fenzi==0||fenmu==0){
	    return;
	}
	long int c=gcd(fenzi,fenmu);
	c=abs(c);
	fenzi=fenzi/c;
	fenmu=fenmu/c;
    }
    long int gcd(long int a,long int b){
	if(b==0){
	    return a;
	}else{
	    gcd(b,a%b);
	}
    }
    friend RationalNum add(RationalNum& r1,RationalNum& r2);
    friend RationalNum jian(RationalNum& r1,RationalNum& r2);
    friend RationalNum product(RationalNum& r1,RationalNum& r2);
    friend RationalNum divide(RationalNum& r1,RationalNum& r2);
    void print();
};
RationalNum add(RationalNum& r1,RationalNum& r2){
    long int a,b;
    b=r1.fenmu*r2.fenmu;
    a=r1.fenzi*r2.fenmu+r2.fenzi*r1.fenmu;
    RationalNum R(a,b);
    R.yuefen();
    return R;
}
RationalNum jian(RationalNum& r1,RationalNum& r2){
    long int a,b;
    b=r1.fenmu*r2.fenmu;
    a=r1.fenzi*r2.fenmu-r2.fenzi*r1.fenmu;
    RationalNum R(a,b);
    R.yuefen();
    return R;
}
RationalNum product(RationalNum& r1,RationalNum& r2){
    long int a,b;
    b=r1.fenmu*r2.fenmu;
    a=r1.fenzi*r2.fenzi;
    RationalNum R(a,b);
    R.yuefen();
    return R;
}
RationalNum divide(RationalNum& r1,RationalNum& r2){
    long int a,b;
    a=r1.fenzi*r2.fenmu;
    b=r1.fenmu*r2.fenzi;
    if(b<0){
	b=-b;
	a=-a;
    }
    RationalNum R(a,b);
    R.yuefen();
    return R;
}
void RationalNum::print(){
    if(fenmu==0){
	cout<<"Inf";
	return;
    }
    long int zheng,yu;
    zheng=abs(fenzi)/fenmu;
    yu=abs(fenzi)%fenmu;
    if(fenzi<0){
	cout<<"(-";
    }
    if(fenmu==1||fenzi==0){//integer
	cout<<abs(fenzi);
    }else if(zheng==0){
	cout<<abs(fenzi)<<"/"<<fenmu;
    }else{
	cout<<zheng<<" "<<yu<<"/"<<fenmu;
    }
    if(fenzi<0){
	cout<<")";
    }
}
int main(){
    long int a,b,c,d;
    scanf("%ld/%ld %ld/%ld",&a,&b,&c,&d);
    RationalNum R1(a,b);
    R1.yuefen();
    RationalNum R2(c,d);
    R2.yuefen();
    RationalNum R3=add(R1,R2);
    RationalNum R4=jian(R1,R2);
    RationalNum R5=product(R1,R2);
    RationalNum R6=divide(R1,R2);
    R1.print();
    cout<<" + ";
    R2.print();
    cout<<" = ";
    R3.print();
    cout<<endl;
    R1.print();
    cout<<" - ";
    R2.print();
    cout<<" = ";
    R4.print();
    cout<<endl;
    R1.print();
    cout<<" * ";
    R2.print();
    cout<<" = ";
    R5.print();
    cout<<endl;
    R1.print();
    cout<<" / ";
    R2.print();
    cout<<" = ";
    R6.print();
    cout<<endl;
}
